/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package loadphase;

import javax.ejb.Stateful;
import javax.ejb.LocalBean;
import javax.ejb.Remove;
import elementos.Composite;
import elementos.Drawable;
import loadphase.*;

/**
 *
 * @author julio
 */
@Stateful
@LocalBean
public class PhaseBean {

    private int currentPhase=0;
    private PhaseLoader loader= new FichPhase();
    
    public Drawable nextPhase(){
        try{
            
            currentPhase++;
            if(currentPhase>10)currentPhase=1;
            System.out.println(currentPhase);
            Composite scene=(Composite) loader.loadPhase(currentPhase);
            return scene;
        }catch(Exception e){
            //currentPhase=0;
            System.out.println("ouch!!");
            return null;
        }        
    }
    
    public Drawable loadPhase(int level){
        setInitialPhase(level);
        return nextPhase();
    }
    
    public void setInitialPhase(int p){
        currentPhase=p-1;
    }
    
    @Remove
    public void finish(){
        
    }
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

}
